package com.nageoffer.shortlink.admin.toolkit;

import java.security.SecureRandom;

/**
 * @Author: 洛辰
 * @En: luochen
 * @Email: luochen@miku.email.cn
 * @CreateTime: 2025-03-23
 * @Description:
 */


public class RandomGenerator {
    private  static  final String CHARACTERS = "0123456789ABCDEFGHIGKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
    private static  final SecureRandom RANDOM = new SecureRandom();

    public static  String generateRandom() {
        return generateRandom(6);
    }

    public static String generateRandom(int length) {
        StringBuilder sb = new StringBuilder(length);
        for(int i = 0; i < length; i++) {
            int randomIndex = RANDOM.nextInt(CHARACTERS.length());
            sb.append(CHARACTERS.charAt(randomIndex));
        }
        return sb.toString();
    }
}
